import request from '@/utils/request'

// 获取问答列表（带过滤条件）
export function getQAList(params) {
  console.log('getQAList params:', params);
  
  return request({
    url: `/qa-management?Page=${params.page}&PageSize=${params.size}&Keyword=${params.search || ''}`,
    method: 'get',
  })
}

// 获取问答详情
export function getQADetail(id) {
  return request({
    url: `/qa-management/${id}`,
    method: 'get'
  })
}

// 创建问答
export function createQA(data) {
  return request({
    url: '/qa-management',
    method: 'post',
    data
  })
}

// 更新问答
export function updateQA(id, data) {
  return request({
    url: `/qa-management/${id}`,
    method: 'put',
    data
  })
}

// 删除问答
export function deleteQA(id) {
  console.log(id);
  
  return request({
    url: `/qa-management/${id}`,
    method: 'delete'
  })
}

// 批量删除问答
export function batchDeleteQA(ids) {
  return request({
    url: '/qa-management/batch',
    method: 'delete',
    data: { ids }
  })
}

// 获取问答统计
export function getQAStatistics() {
  return request({
    url: '/qa-management/statistics',
    method: 'get'
  })
}

// 导出问答数据
export function exportQAData(data) {
  return request({
    url: '/qa-management/export',
    method: 'post',
    data
  })
}

// 搜索问答
export function searchQA(params) {
  return request({
    url: '/qa-management/search',
    method: 'get',
    params
  })
}

// 生成问答
export function generateQA(data) {
  return request({
    url: '/qa/generate',
    method: 'post',
    data
  })
}

// 检索问答
export function retrieveQA(data) {
  return request({
    url: '/qa/retrieve',
    method: 'post',
    data
  })
}

// 获取用户对话记录
export function getUserConversations(data) {
  return request({
    url: '/qa/user-conversations',
    method: 'post',
    data
  })
}

// 获取问答会话
export function getQASessions(params) {
  return request({
    url: '/qa/sessions',
    method: 'get',
    params
  })
}

// 创建问答会话
export function createQASession(data) {
  return request({
    url: '/qa/sessions',
    method: 'post',
    data
  })
}

// 发送会话消息
export function sendSessionMessage(sessionId, data) {
  return request({
    url: `/qa/sessions/${sessionId}/messages`,
    method: 'post',
    data
  })
}
